﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ModelLayer;
using DBLayer;

namespace CtrLayer
{
    public class MovieController
    {
        IMovieDB movieDb = new MovieDBClient();

        public Movie GetMovie(string title)
        {
            return movieDb.GetMovie(title);
        }

        public List<Movie> GetMovies(DateTime dateTime)
        {
            return movieDb.GetMovies(dateTime);
        }

        public int AddMovie(bool active, string title, int playLength, string actor, int minAge, string description, string rating, string director, string genre, string language, decimal price, string licencee, DateTime rentalDateStart, DateTime rentalDateEnd)
        {
            Movie m = new Movie(active, title, playLength, actor, minAge, description, rating, director, genre, language, price, licencee, rentalDateStart, rentalDateEnd);
            return movieDb.InsertMovie(m);
        }

        public int UpdateMovie(int id, bool active, string title, int playLength, string actor, int minAge, string description, string rating, string director, string genre, string language, decimal price, string licencee, DateTime rentalDateStart, DateTime rentalDateEnd)
        {
            Movie m = new Movie(id, active, title, playLength, actor, minAge, description, rating, director, genre, language, price, licencee, rentalDateStart, rentalDateEnd);
            return movieDb.UpdateMovie(m);
        }

        public int DeleteMovie(int id)
        {
            return movieDb.DeleteMovie(id);
        }

        public List<Movie> FindMovies(string input, string category)
        {
            if (category.Equals("Skuespiller"))
                category = "actors";
            else if (category.Equals("Titel"))
                category = "title";
            else if (category.Equals("Beskrivelse"))
                category = "description";
            else if (category.Equals("Instruktør"))
                category = "director";
            else if (category.Equals("Kategori"))
                category = "genre";
            else if (category.Equals("Sprog"))
                category = "language";
            else if (category.Equals("Aktiv"))
                category = "active";
            else
                category = "all";
            return movieDb.FindMovies(input, category);
        }
    }
}
